/***
Description:Packet header file
***/

#ifndef PACKET_H
#define PACKET_H

#define PACKET_SIZE 161
#define HEADER_SIZE 32

#define ACK -10
#define CORRUPTED_ACK -100

typedef struct tagPacket 
{
	int seqnum;
	int acknum;
	int checksum;
	char payload[PACKET_SIZE];
} packet;

// create a single packet
int createPacket(packet* new_pck, FILE* fd, int seq_num);

// fill the header of the packet
int fill_header(packet* new_pck, int seq_num, int ack_num, int check_sum);

// calculate checksum of the packet
// use the algorithm in the book
// checksum = ACK + SEQ + each byte of payload
int calculateChecksum(packet* pck);

#endif
